package com.xxx.video.mine.adapters;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.widget.RadioButton;

import androidx.annotation.NonNull;


import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.FontCacheUtils;
import com.xxx.video.commen.views.FontTextView;
import com.xxx.video.mine.beans.FeedBackTypeListBean;

import butterknife.BindView;

public class FeedBackTypeListAdapter extends BaseRecycleViewAdapter<FeedBackTypeListBean.ListBean, FeedBackTypeListAdapter.MyHolder> {
    /**
     * currentPosition
     */
    public int mCurrentPosition = 0;

    public FeedBackTypeListAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_feed_back_type_list;
    }

    class MyHolder extends BaseViewHolder {
        @BindView(R.id.rb_feed_back_type_list)
        RadioButton rbFeedBackTypeList;

        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            FeedBackTypeListBean.ListBean listBean = getItem(position);
            rbFeedBackTypeList.setChecked(false);
            if (position == mCurrentPosition) {
                rbFeedBackTypeList.setChecked(true);
            }
            Typeface customFont = FontCacheUtils.getInstance().getTypeface(FontTextView.ttf3, context);
            rbFeedBackTypeList.setTypeface(customFont);
            rbFeedBackTypeList.setText(listBean.fDatadictName);
            rbFeedBackTypeList.setOnClickListener(v -> {
                mCurrentPosition = position;
                notifyDataSetChanged();
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(listBean, position, 0);
                }
            });
        }
    }
}
